package com.keyancompany.zhongbaopingtai.weight;

import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.PopupWindow;

import butterknife.ButterKnife;


public abstract class MenuPopuWindow extends PopupWindow {

    public Context context;
    protected View contentView;
    protected ClickSureListener cliclSureListener;

    public void setCliclSureListener(ClickSureListener cliclSureListener) {
        this.cliclSureListener = cliclSureListener;
    }



    public interface ClickSureListener {
        void clickSureLinstener(String... param);
    }

    public MenuPopuWindow(Context context) {
        super(context);
        this.context = context;
//		LayoutInflater inflater = LayoutInflater.from(context);
//
//		contentView= inflater.inflate(getResView(),null);
        contentView = View.inflate(context, getResView(), null);

        setContentView(contentView);
        ButterKnife.bind(this, contentView);
        if (getAnimationStyle() != 0) {
            setAnimationStyle(getAnimationStyle());
        }
        setUpViews();
        setWidth(LayoutParams.MATCH_PARENT);
        setHeight(LayoutParams.WRAP_CONTENT);
        setBackgroundDrawable(new BitmapDrawable());
        updateView(contentView);
        setFocusable(true);
        setOutsideTouchable(true);

        setUpListener();
    }

    public View findViewById(int id) {
        View view = null;
        if (contentView != null) {
            view = contentView.findViewById(id);
        }
        return view;
    }

    public abstract void setUpViews();

    public abstract void setUpListener();

    public abstract int getAnimationStyle();

    public abstract int getResView();

    public abstract void updateView(View contentView);

    public void setAttribute(int width, int Height) {
        setWidth(width);
        setHeight(Height);
    }

}
